﻿namespace CN2P.Tests
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class RecommendationsServiceTest : BaseServiceTest
    {
        [TestMethod]
        [TestCategory("Recommendation")]
        public void recommendationWalkthroughTest()
        {
            //this.Service.ProductsService.DeleteAll();
            //this.Service.RecommendationsService.DeleteAll();

            var prod1 = this.CreateRandomProduct();
            var prod2 = this.CreateRandomProduct();
            var prod3 = this.CreateRandomProduct();
            var prod4 = this.CreateRandomProduct();

            this.Service.RecommendationsService.AddTraversal(prod1.ProdId, prod2.ProdId);
            this.Service.RecommendationsService.AddTraversal(prod1.ProdId, prod3.ProdId);
            this.Service.RecommendationsService.AddTraversal(prod2.ProdId, prod3.ProdId);
            this.Service.RecommendationsService.AddTraversal(prod4.ProdId, prod3.ProdId);

            //Add some ratings
            this.Service.RecommendationsService.AddRating(prod1.ProdId, 1f);
            this.Service.RecommendationsService.AddRating(prod1.ProdId, 3.5f);
            this.Service.RecommendationsService.AddRating(prod2.ProdId, 2f);
            this.Service.RecommendationsService.AddRating(prod3.ProdId, 4.5f);

            var res = this.Service.RecommendationsService.Get(new[] { prod1.ProdId, prod4.ProdId });

            Assert.AreEqual(2, res.Count); 
            Assert.IsTrue(res.Contains(prod2.ProdId));
            Assert.IsTrue(res.Contains(prod3.ProdId));
        }
    }
}
